"""
    @author RinMi
    @since  2024/6/13  
"""
import re


def get_text():
    with open(file='sql1.txt', mode='r', encoding='utf-8') as file:
        text = file.read()
        file.close()
        return text


def trans_text(text):
    regex = r'`.+?`'
    text = str(text).replace('mysql', 'dameng').replace(" or dbType == 'h2'", '')
    matches = set(item for item in re.findall(regex, text))
    for mat in matches:
        text = text.replace(mat, str(mat).replace('`', '\"').upper())
    return text


def set_text(text):
    with open(file='sql1.txt', mode='w', encoding='utf-8') as file:
        file.write(text)
        file.close()


if __name__ == '__main__':
    content = get_text()
    content = trans_text(content)
    set_text(content)
